﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Mapping;

namespace ZavrsniRad
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();   
            dal = new DAL();
         
        }

        
        private IList<Research> researches;
        private DAL dal;

       



        
    

      

       

        private void frmMain_Load(object sender, EventArgs e)
        {

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtBox.Clear();
        }

        private void bntReadResearch_Click(object sender, EventArgs e)
        {
            researches=dal.LoadResearchesFromDatabase();
            foreach (Research res in researches)
            {
                txtBox.Text += res.Name + " " 
                    + res.Summary + "  " + res.AccessTime + "\r\n";
            }
        }

        private void btnAddResearch_Click(object sender, EventArgs e)
        {
            dal.CreateResearchAndSaveToDatabase();
        }

        private void btnUpdateRes_Click(object sender, EventArgs e)
        {
            dal.UpdateResearch();
        }

        private void btn_Click(object sender, EventArgs e)
        {
            Form frm = new frmResearch(dal);
            frm.Show();
        }

      

  

       
    }
}
